package com.amc.configs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;

public class test {

	public static void main(String[] args) {
		HttpURLConnection conn;
		List<String> list = new ArrayList<>();
		try {// 10.222.29.195
			URL url = new URL(
					"http://10.222.29.195:8080/amc-a-v3/admin/advertisement/getAdvertisementList");
			conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod("GET");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.connect();
			String result = "";
			int resCode = conn.getResponseCode();
			if (resCode == 200) {
				InputStream is = conn.getInputStream();
				BufferedReader br = new BufferedReader(
						new InputStreamReader(is));
				String line = "";
				while ((line = br.readLine()) != null) {
					result += line;
				}
			}
			ObjectMapper mapper = new ObjectMapper();
			list = mapper.readValue(result, List.class);
			System.out.println(result);
		} catch (IOException e) {
			System.out.println("服务器未开启");
			e.printStackTrace();
		}

	}

}
